<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>index</title>
</head>
<body>
<h1>111</h1>
<button onclick="ajaxTest()">按钮</button>
<script>
    const xmlhttp = new XMLHttpRequest();

    function ajaxTest(){

        xmlhttp.open("GET","/user/1",true);
        xmlhttp.send();
        setTimeout("f()",1000);//防止异步执行,后台还未来得及放回结果发生错误
    }

    function f() {
        alert(xmlhttp.responseText);
        alert(xmlhttp.readyState);
        alert(xmlhttp.status);
    }

</script>

</body>
</html>